﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SIGERP_Negocio;
using SIGERP_Entidades;

namespace SIGERP_Presentacion
{
    public partial class frmTipoReclamoAgregar : Form
    {

        private ErrorProvider ep = new ErrorProvider();
        public Boolean agrego = false;

        public frmTipoReclamoAgregar()
        {
            InitializeComponent();
        }

        public frmTipoReclamoAgregar(String tipo_reclamo)
        {
            InitializeComponent();
            txtTipoReclamo.Text=tipo_reclamo;
        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {

            ep.Clear();
            
            if (txtTipoReclamo.Text.Equals(""))
            {
                ep.SetError(txtTipoReclamo, "Este campo es obligatorio");
                txtTipoReclamo.Focus();
                return;
            }

            if (TiposReclamo.verificarSiExiste(txtTipoReclamo.Text.ToUpper()))
            {
                MessageBox.Show("El Tipo de reclamo ingresado ya existe", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }

            else
            {
                nuevoTipoReclamo();
            }

            }

            

        private void nuevoTipoReclamo()
        {
            TipoReclamo tr = new TipoReclamo();
            tr.descripcion = txtTipoReclamo.Text.ToUpper();
            TiposReclamo.Agregar(tr);
            agrego = true;
            Close();
        }   

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void toolStripAyuda_Click(object sender, EventArgs e)
        {
            Utilities.mostrarAyuda(this, (this.GetType().ToString() + ".htm").Replace("SIGERP_Presentacion.", ""));
        }
    }
}
